﻿using System.Collections.Generic;
using BKO.Domain.Model;

namespace BKO.DataAccesss
{
	public partial class Unit : IUnit
	{
		private string _place;

		public ICabinet Cabinet
		{
			get { return CabinetEntity; }
		}

		public IFilial Filial
		{
			get { return FilialEntity; }
		}

		public IOtdel Otdel
		{
			get { return OtdelEntity; }
		}

		public string Place
		{
			get
			{
				if (_place == null)
				{
					List<string> places = new List<string>();
					if (!string.IsNullOrEmpty(FilialEntity.Name))
					{
						places.Add(FilialEntity.Name);
					}
					if (!string.IsNullOrEmpty(OtdelEntity.Name))
					{
						places.Add(OtdelEntity.Name);
					}
					if (!string.IsNullOrEmpty(CabinetEntity.Name))
					{
						places.Add(CabinetEntity.Name);
					}
					_place = string.Join("/", places);
				}
				return _place;
			}
		}
	}
}
